package com.zhangxin.aiInterview;

import com.google.gson.JsonStreamParser;
import com.zhangxin.aiInterview.manager.knoewlege_base_api.ExamQuestionParser;
import com.zhangxin.aiInterview.manager.knoewlege_base_api.dto.ExamQuestionWrapper;
import org.junit.jupiter.api.Test;

public class JsonstrToObject {
    @Test
    void test(){
        String json = "```json\n" +
                "[ \n" +
                "    { \n" +
                "        \"type\": 1, \n" +
                "        \"question\": [ \n" +
                "            { \n" +
                "                \"title\": \"以下哪个是Java的基本数据类型？\", \n" +
                "                \"option\": [ \n" +
                "                    {\"value\": \"Integer\", \"key\": \"A\"}, \n" +
                "                    {\"value\": \"int\", \"key\": \"B\"}, \n" +
                "                    {\"value\": \"Long\", \"key\": \"C\"}, \n" +
                "                    {\"value\": \"String\", \"key\": \"D\"} \n" +
                "                ] \n" +
                "            }, \n" +
                "            { \n" +
                "                \"title\": \"Java中实现线程安全集合的类是？\", \n" +
                "                \"option\": [ \n" +
                "                    {\"value\": \"ArrayList\", \"key\": \"A\"}, \n" +
                "                    {\"value\": \"Vector\", \"key\": \"B\"}, \n" +
                "                    {\"value\": \"LinkedList\", \"key\": \"C\"}, \n" +
                "                    {\"value\": \"HashMap\", \"key\": \"D\"} \n" +
                "                ] \n" +
                "            }, \n" +
                "            { \n" +
                "                \"title\": \"Spring中控制反转(IoC)的实现方式是？\", \n" +
                "                \"option\": [ \n" +
                "                    {\"value\": \"工厂模式\", \"key\": \"A\"}, \n" +
                "                    {\"value\": \"代理模式\", \"key\": \"B\"}, \n" +
                "                    {\"value\": \"依赖注入\", \"key\": \"C\"}, \n" +
                "                    {\"value\": \"观察者模式\", \"key\": \"D\"} \n" +
                "                ] \n" +
                "            }, \n" +
                "            { \n" +
                "                \"title\": \"MySQL中InnoDB引擎的默认隔离级别是？\", \n" +
                "                \"option\": [ \n" +
                "                    {\"value\": \"Read Uncommitted\", \"key\": \"A\"}, \n" +
                "                    {\"value\": \"Read Committed\", \"key\": \"B\"}, \n" +
                "                    {\"value\": \"Repeatable Read\", \"key\": \"C\"}, \n" +
                "                    {\"value\": \"Serializable\", \"key\": \"D\"} \n" +
                "                ] \n" +
                "            }, \n" +
                "            { \n" +
                "                \"title\": \"Redis的持久化机制不包括？\", \n" +
                "                \"option\": [ \n" +
                "                    {\"value\": \"RDB\", \"key\": \"A\"}, \n" +
                "                    {\"value\": \"AOF\", \"key\": \"B\"}, \n" +
                "                    {\"value\": \"Memcache\", \"key\": \"C\"}, \n" +
                "                    {\"value\": \"混合持久化\", \"key\": \"D\"} \n" +
                "                ] \n" +
                "            } \n" +
                "        ] \n" +
                "    }, \n" +
                "    { \n" +
                "        \"type\": 2, \n" +
                "        \"question\": [ \n" +
                "            \"简述JVM内存模型及垃圾回收算法\", \n" +
                "            \"HashMap的底层实现原理及扩容机制\", \n" +
                "            \"Spring Bean的生命周期管理过程\" \n" +
                "        ] \n" +
                "    }, \n" +
                "    { \n" +
                "        \"type\": 3, \n" +
                "        \"question\": [ \n" +
                "            \"实现生产者-消费者模型，要求：使用阻塞队列，支持多生产者多消费者，防止内存溢出\", \n" +
                "            \"给定非降序数组和目标值，实现二分查找\" \n" +
                "        ] \n" +
                "    } \n" +
                "]\n" +
                "```";
            String cleanJson = json.replace("```json", "").replace("```", "").trim();
//        System.out.println(cleanJson);
        ExamQuestionWrapper examQuestionWrapper = ExamQuestionParser.parseExamQuestions(cleanJson);
        System.out.println(examQuestionWrapper);

    }
}
